import React from 'react';
import { observable, computed, action, toJS } from 'mobx';
//import { IDataSetCard, dataSetInfo, dataSetGroupWithDsList } from '../../../../apis/dataset';
import { WeaLocaleProvider } from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
export const CellType = {
    Const : 'Const',
    Field : 'Field',
    Formula : 'Formula',
    DateTime : 'DateTime',
    SequenceNumber : 'SequenceNumber'
}

export const FormatterTypeEnum = {
    common: "",
    value: getLabel('526912','数值格式用于一般数字的表示。货币和会计格式则提供货币值计算的专用格式。'),
    huobi: getLabel('526913','货币格式用于表示一般货币数值。会计格式可对一列数值进行小数点对齐'),
    kuaiji: getLabel('526914','会计格式可对一列数值进行货币符号和小数点对齐。'),
    date: getLabel('526915','日期格式把日期和时间系列数显示为日期值。'),
    time: getLabel('526916','时间格式把日期和时间序列数显示为时间值。'),
    percent:getLabel('526917','以百分数的形式显示单元格的值。'),
    fenshu: "",
    kexuejishu: "",
    text: "",
    special: getLabel('526918','特殊格式可用于跟踪数据列表及数据库的值。') ,
    custom: getLabel('526919','以现有格式为基础，生成自定义的数字格式。') ,
    
}

export default class FormatterSettingDialog extends React.Component{
    @observable mainVisible = false;
    @observable selectionVisible = false;
    cache = {};
    cellType = CellType.Field;
    ///////////////数字格式/////////////////
    FormatterType = [
        { key: 'common', showname: getLabel('521044','常规') },
        { key: 'value', showname: getLabel('521042','数值') },
        { key: 'huobi', showname: getLabel('521108','货币') },
        { key: 'kuaiji', showname: getLabel('521109','会计专用') },
        { key: 'date', showname: getLabel('502297','日期') },
        { key: 'time', showname: getLabel('502541','时间') },
        { key: 'percent', showname: getLabel('521110','百分比') },
        { key: 'fenshu', showname: getLabel('521111','分数') },
        { key: 'kexuejishu', showname: getLabel('521548','科学记数') },
        { key: 'text', showname: getLabel('502305','文本') },
        { key: 'special', showname: getLabel('521113','特殊') },
        { key: 'custom', showname: getLabel('502465', '自定义') },
    ];

    @observable valueType = [
        { key: '1', showname1: '(', showname2: '1', showname: '234', showname3: ')', color: 'red' },
        { key: '2', showname1: '(', showname2: '1', showname: '234', showname3: ')' },
        { key: '3', showname1: '', showname2: '1', showname: '234', showname3: '', color: 'red' },
        { key: '4', showname1: '', showname2: '-1', showname: '234', showname3: '' },
        { key: '5', showname1: '', showname2: '-1', showname: '234', showname3: '', color: 'red' },
    ]

    @observable specialType = [
        { showname: getLabel('526857','邮政编码'), key: '000000' },
        { showname: getLabel('526858','中文小写数字'), key: '[DBNum1][$-804]General' },
        { showname: getLabel('526859','中文大写数字'), key: '[DBNum2][$-804]General' },
        { showname: getLabel('526860','中文大写数字2'), key: '[DBNum3][$-804]General' },
        { showname: getLabel('526861','人民币大写') , key: '[DBNum2][$RMB]General;[Red][DBNum2][$RMB]General' },
        { showname: getLabel('526862','单位：万元'), key: 'dwwy' },
        { showname: getLabel('526863','正负号'), key: 'zfh' },
    ]

    @observable specialUnitType = [
        { showname: getLabel('526864','万') , key: '0"."0,"'+getLabel('526864','万') +'"' },
        { showname: getLabel('526865','百万'), key: '0.00,,"'+getLabel('526865','百万') +'"' },
        { showname: getLabel('526866','千万'), key: '0"."0,,"'+getLabel('526866','千万')+'"' },
        { showname: getLabel('526867','万元'), key: '0"."0,"'+getLabel('526867','万元')+'"' },
        { showname: getLabel('526868','百万元'), key: '0.00,,"'+getLabel('526868','百万元') +'"' },
        { showname: getLabel('526869','千万元') , key: '0"."0,,"'+getLabel('526869','千万元') +'"' },
        { showname: getLabel('526870','亿元'), key: '0"."00,,"'+getLabel('526870','亿元')+'"' },

    ]

    @observable specialSignType = [
        { key: '\+0;\-0;0;@', showname: '+26', showname2: ' -18' },
        { key: '\+0;[Red]\-0;0;@', showname: '+26', showname2: ' -18', color: 'red' },
    ]

    @observable dateFormatterType = [
        { showname: getLabel('526871','2001年3月7日') , key: getLabel('526872','yyyy"年"m"月"d"日";@')  },
        { showname: getLabel('526873','2001年3月') , key: getLabel('526874','yyyy"年"m"月";@')  },
        { showname: getLabel('526875','二〇〇一年三月七日') , key: getLabel('526876','[DBNum1][$-804]yyyy"年"m"月"d"日";@')  },
        { showname: getLabel('526877','二〇〇一年三月') , key: getLabel('526878','[DBNum1][$-804]yyyy"年"m"月";@')},
        { showname: getLabel('526879','三月七日') , key: getLabel('526880','[DBNum1][$-804]m"月"d"日";@') },
        { showname: getLabel('526881','3月7日'), key: getLabel('526882','m"月"d"日";@') },
        { showname: getLabel('526884','星期三') , key: '[$-804]aaaa;@' },
        { showname: getLabel('526883','三'), key: '[$-804]aaa;@' },
        { showname: '2001/3/7', key: 'yyyy/m/d;@' },
        { showname: '2001/3/7 12:00 AM', key: '[$-409]yyyy/m/d\ h:mm\ AM/PM;@' },
        { showname: '2001/3/7 0:00', key: 'yyyy/m/d\ h:mm;@' },
        { showname: '01/3/7', key: 'yy/m/d;@' },
        { showname: '3/7', key: 'm/d;@' },
        { showname: '3/7/01', key: 'm/d/yy;@' },
        { showname: '03/07/01', key: 'mm/dd/yy;@' },
        { showname: '7-Mar', key: '[$-409]d\-mmm;@' },
        { showname: '7-Mar-01', key: '[$-409]d\-mmm\-yy;@' },
        { showname: '07-Mar-01', key: '[$-409]dd\-mmm\-yy;@' },
        { showname: 'Mar-01', key: '[$-409]mmm\-yy;@' },
        { showname: 'March-01', key: '[$-409]mmmm\-yy;@' },
        { showname: 'M', key: '[$-409]mmmmm;@' },
        { showname: 'M-01', key: '[$-409]mmmmm\-yy;@' },
    ]

    @observable timeFormatterType = [
        { showname: '16:22:30', key: 'h:mm:ss;@' },
        { showname: '4:22:30 PM', key: '[$-409]h:mm:ss\ AM/PM;@' },
        { showname: '16:22', key: 'h:mm;@' },
        { showname: '4:22 PM', key: '[$-409]h:mm\ AM/PM;@' },
        { showname: getLabel('526885','16时22分') , key: getLabel('526886','h"时"mm"分";@')  },
        { showname: getLabel('526887','4时22分 PM') , key: getLabel('526888','[$-409]h"时"mm"分"\ AM/PM;@')  },
        { showname: getLabel('526889','16时22分30秒'), key: getLabel('526890','h"时"mm"分"ss"秒";@') },
        { showname: getLabel('526891','4时22分30秒 PM') , key: getLabel('526892','[$-409]h"时"mm"分"ss"秒" AM/PM;@')  },
        { showname: getLabel('526893','下午4时22分') , key: getLabel('526894','上午/下午h"时"mm"分";@') },
        { showname: getLabel('526895','下午4时22分30秒') , key: getLabel('526896','上午/下午h"时"mm"分"ss"秒";@')  },
        { showname: getLabel('526897','十六时二十二分') , key: getLabel('526898','[DBNum1][$-804]h"时"mm"分";@') },
        { showname: getLabel('526899','下午四时二十二分') , key: getLabel('526900','[DBNum1][$-804]上午/下午h"时"mm"分";@')  },
    ]

    @observable fenshuType = [
        { showname: getLabel('526901','分母为一位数(1/2)') , key: '#\ ?/?' },
        { showname: getLabel('526902','分母为两位数(22/45)') , key: '#\ ??/??' },
        { showname: getLabel('526903','分母为三位数(289/591)') , key: '#\ ???/???' },
        { showname: getLabel('526904','以2为分母(1/2)') , key: '#\ ?/2' },
        { showname: getLabel('526905','以4为分母(2/4)') , key: '#\ ?/4' },
        { showname: getLabel('526906','以8为分母(4/8)'), key: '#\ ?/8' },
        { showname: getLabel('526907','以16为分母(8/16)') , key: '#\ ??/16' },
        { showname: getLabel('526908','以10为分母(5/10)'), key: '#\ ?/10' },
        { showname: getLabel('526909','百分之几(49/100)') , key: '#\ ??/100' },
    ]

    @observable customType = [
        { showname: getLabel('526910','G/通用格式') , key: getLabel('526910','G/通用格式')},
        { showname: '0', key: '0' },
        { showname: '0.00', key: '0.00' },
        { showname: '#,##0', key: '#,##0' },
        { showname: '#,##0.00', key: '#,##0.00' },
        { showname: '_ * #,##0_ ;_ * -#,##0_ ;_ * "-"_ ;_ @_ ', key: '_ * #,##0_ ;_ * -#,##0_ ;_ * "-"_ ;_ @_ ' },
        { showname: '_ * #,##0.00_ ;_ * -#,##0.00_ ;_ * "-"??_ ;_ @_ ', key: '_ * #,##0.00_ ;_ * -#,##0.00_ ;_ * "-"??_ ;_ @_ ' },
        { showname: '_ ￥* #,##0_ ;_ ￥* -#,##0_ ;_ ￥* "-"_ ;_ @_ ', key: '_ ￥* #,##0_ ;_ ￥* -#,##0_ ;_ ￥* "-"_ ;_ @_ ' },
        { showname: '_ ￥* #,##0.00_ ;_ ￥* -#,##0.00_ ;_ ￥* "-"??_ ;_ @_ ', key: '_ ￥* #,##0.00_ ;_ ￥* -#,##0.00_ ;_ ￥* "-"??_ ;_ @_ ' },
        { showname: '#,##0;-#,##0', key: '#,##0;-#,##0' },
        { showname: '#,##0;['+[getLabel('526939','红色')]+']-#,##0', key: '#,##0;['+getLabel('526939','红色')+']-#,##0' },
        { showname: '#,##0.00;-#,##0.00', key: '#,##0.00;-#,##0.00' },
        { showname: '#,##0.00;['+getLabel('526939','红色')+']-#,##0.00', key: '#,##0.00;['+getLabel('526939','红色')+']-#,##0.00' },
        { showname: '￥#,##0;￥-#,##0', key: '￥#,##0;￥-#,##0' },
        { showname: '￥#,##0;['+getLabel('526939','红色')+']￥-#,##0', key: '￥#,##0;['+getLabel('526939','红色')+']￥-#,##0' },
        { showname: '￥#,##0.00;￥-#,##0.00', key: '￥#,##0.00;￥-#,##0.00' },
        { showname: '￥#,##0.00;['+getLabel('526939','红色')+']￥-#,##0.00', key: '￥#,##0.00;['+getLabel('526939','红色')+']￥-#,##0.00' },
        { showname: '0%', key: '0%' },
        { showname: '0.00%', key: '0.00%' },
        { showname: '0.00E+00', key: '0.00E+00' },
        { showname: '##0.0E+0', key: '##0.0E+0' },
        { showname: '# ?/?', key: '# ?/?' },
        { showname: '# ??/??', key: '# ??/??' },
        { showname: '$#,##0_);($#,##0)', key: '$#,##0_);($#,##0)' },
        { showname: '$#,##0_);['+getLabel('526939','红色')+']($#,##0)', key: '$#,##0_);['+getLabel('526939','红色')+']($#,##0)' },
        { showname: '$#,##0.00_);($#,##0.00)', key: '$#,##0.00_);($#,##0.00)' },
        { showname: '$#,##0.00_);['+getLabel('526939','红色')+']($#,##0.00)', key: '$#,##0.00_);['+getLabel('526939','红色')+']($#,##0.00)' },
        { showname: 'mm:ss.0', key: 'mm:ss.0' },
        { showname: 'yyyy/m/d', key: 'yyyy/m/d' },
        { showname: getLabel('526937','[DBNum1][$-804]yyyy"年"m"月"d"日"') , key: getLabel('526937','[DBNum1][$-804]yyyy"年"m"月"d"日"')  },
        { showname: getLabel('526936','[DBNum1][$-804]yyyy"年"m"月"'), key: getLabel('526936','[DBNum1][$-804]yyyy"年"m"月"') },
        { showname: getLabel('526935','[DBNum1][$-804]m"月"d"日"'), key: getLabel('526935','[DBNum1][$-804]m"月"d"日"') },
        { showname: getLabel('526934','yyyy"年"m"月"d"日"'), key: getLabel('526934','yyyy"年"m"月"d"日"') },
        { showname: getLabel('526940','yyyy"年"m"月"') , key: getLabel('526940','yyyy"年"m"月"')  },
        { showname: getLabel('526933','m"月"d"日"') , key: getLabel('526933','m"月"d"日"')  },
        { showname: '[$-804]aaaa', key: '[$-804]aaaa' },
        { showname: '[$-804]aaa', key: '[$-804]aaa' },
        { showname: 'yyyy/m/d h:mm AM/PM', key: 'yyyy/m/d h:mm AM/PM' },
        { showname: 'yyyy/m/d h:mm', key: 'yyyy/m/d h:mm' },
        { showname: 'yy/m/d', key: 'yy/m/d' },
        { showname: 'm/d', key: 'm/d' },
        { showname: 'm/d/yy', key: 'm/d/yy' },
        { showname: 'mm/dd/yy', key: 'mm/dd/yy' },
        { showname: 'd-mmm', key: 'd-mmm' },
        { showname: 'd-mmm-yy', key: 'd-mmm-yy' },
        { showname: 'dd-mmm-yy', key: 'dd-mmm-yy' },
        { showname: 'mmm-yy', key: 'mmm-yy' },
        { showname: 'mmmm-yy', key: 'mmmm-yy' },
        { showname: 'mmmmm', key: 'mmmmm' },
        { showname: 'mmmmm-yy', key: 'mmmmm-yy' },
        { showname: 'h:mm', key: 'h:mm' },
        { showname: 'h:mm AM/PM', key: 'h:mm AM/PM' },
        { showname: 'h:mm:ss', key: 'h:mm:ss' },
        { showname: 'h:mm:ss AM/PM', key: 'h:mm:ss AM/PM' },
        { showname: getLabel('526932','h"时"mm"分"'), key: getLabel('526932','h"时"mm"分"') },
        { showname: getLabel('526931','h"时"mm"分"ss"秒"') , key: getLabel('526931','h"时"mm"分"ss"秒"')  },
        { showname: getLabel('526930','上午/下午h"时"mm"分"'), key: getLabel('526930','上午/下午h"时"mm"分"') },
        { showname: getLabel('526929','上午/下午h"时"mm"分"ss"秒"') , key: getLabel('526929','上午/下午h"时"mm"分"ss"秒"')  },
        { showname: getLabel('526928','[DBNum1]h"时"mm"分"') , key: getLabel('526928','[DBNum1]h"时"mm"分"')  },
        { showname: getLabel('526927','[DBNum1]上午/下午h"时"mm"分"') , key: getLabel('526927','[DBNum1]上午/下午h"时"mm"分"')  },
        { showname: '@', key: '@' },
        { showname: 'mm:ss', key: 'mm:ss' },
        { showname: '[h]:mm:ss', key: '[h]:mm:ss' },
        { showname: '¥#,##0;¥-#,##0', key: '¥#,##0;¥-#,##0' },
        { showname: '¥#,##0;['+getLabel('526939','红色')+']¥-#,##0', key: '¥#,##0;['+getLabel('526939','红色')+']¥-#,##0' },
        { showname: '¥#,##0.00;¥-#,##0.00', key: '¥#,##0.00;¥-#,##0.00' },
        { showname: '¥#,##0.00;['+getLabel('526939','红色')+']¥-#,##0.00', key: '¥#,##0.00;['+getLabel('526939','红色')+']¥-#,##0.00' },
        { showname: '0.00000%', key: '0.00000%' },
        { showname: '# ?/8', key: '# ?/8' },
        { showname: '[$-409]dd-mmm-yy;@', key: '[$-409]dd-mmm-yy;@' },
        { showname: '#,##0.0000_);(#,##0.0000)', key: '#,##0.0000_);(#,##0.0000)' },
        { showname: 'm/d;@', key: 'm/d;@' },
        { showname: '[$-409]d-mmm;@', key: '[$-409]d-mmm;@' },
        { showname: '￥#,##0.00_);(￥#,##0.00)', key: '￥#,##0.00_);(￥#,##0.00)' },
        { showname: '#,##0.0000_);['+getLabel('526939','红色')+'](#,##0.0000)', key: '#,##0.0000_);['+getLabel('526939','红色')+'](#,##0.0000)' },
        { showname: '#,##0.0000;['+getLabel('526939','红色')+']#,##0.0000', key: '#,##0.0000;['+getLabel('526939','红色')+']#,##0.0000' },
        { showname: '#,##0.0000_ ', key: '#,##0.0000_ ' },
        { showname: '[$-409]yyyy/m/d h:mm AM/PM;@', key: '[$-409]yyyy/m/d h:mm AM/PM;@' },
        { showname: '#,##0.0000_ ;['+getLabel('526939','红色')+']-#,##0.0000 ', key: '#,##0.0000_ ;['+getLabel('526939','红色')+']-#,##0.0000 ' },
        { showname: '[$-409]mmmmm;@', key: '[$-409]mmmmm;@' },
        { showname: 'mm/dd/yy;@', key: 'mm/dd/yy;@' },
        { showname: '#,##0_ ', key: '#,##0_ ' },
        { showname: '0.0000;['+getLabel('526939','红色')+']0.0000', key: '0.0000;['+getLabel('526939','红色')+']0.0000' },
        { showname: '[$-409]mmmm-yy;@', key: '[$-409]mmmm-yy;@' },
        { showname: 'yyyy/m/d h:mm;@', key: 'yyyy/m/d h:mm;@' },
        { showname: 'US$#,##0.00;['+getLabel('526939','红色')+']-"US$"#,##0.00', key: 'US$#,##0.00;['+getLabel('526939','红色')+']-"US$"#,##0.00' },
        { showname: '￥#,##0.00_);['+getLabel('526939','红色')+'](￥#,##0.00)', key: '￥#,##0.00_);['+getLabel('526939','红色')+'](￥#,##0.00)' },
        { showname: 'yy/m/d;@', key: 'yy/m/d;@' },
        { showname: getLabel('526880','[DBNum1][$-804]m"月"d"日";@'), key: getLabel('526880','[DBNum1][$-804]m"月"d"日";@') },
        { showname: '€#,##0.00;['+getLabel('526939','红色')+']"€"#,##0.00', key: '€#,##0.00;['+getLabel('526939','红色')+']"€"#,##0.00' },
        { showname: '0.000000%', key: '0.000000%' },
        { showname: '# ?/4', key: '# ?/4' },
        { showname:getLabel('526882','m"月"d"日";@'), key: getLabel('526882','m"月"d"日";@') },
        { showname: getLabel('526876','[DBNum1][$-804]yyyy"年"m"月"d"日";@'), key: getLabel('526876','[DBNum1][$-804]yyyy"年"m"月"d"日";@') },
        { showname: '_ ￥* #,##0.0000_ ;_ ￥* -#,##0.0000_ ;_ ￥* "-"????_ ;_ @_ ', key: '_ ￥* #,##0.0000_ ;_ ￥* -#,##0.0000_ ;_ ￥* "-"????_ ;_ @_ ' },
        { showname: '[$-409]mmm-yy;@', key: '[$-409]mmm-yy;@' },
        { showname: getLabel('526878','[DBNum1][$-804]yyyy"年"m"月";@'), key: getLabel('526878','[DBNum1][$-804]yyyy"年"m"月";@') },
        { showname: '_ "€"* #,##0.00_ ;_ "€"* -#,##0.00_ ;_ "€"* "-"??_ ;_ @_ ', key: '_ "€"* #,##0.00_ ;_ "€"* -#,##0.00_ ;_ "€"* "-"??_ ;_ @_ ' },
        { showname: 'yyyy/m/d;@', key: 'yyyy/m/d;@' },
        { showname: '[$-804]aaaa;@', key: '[$-804]aaaa;@' },
        { showname: '_-"US$"* #,##0.0000000_ ;_-"US$"* -#,##0.0000000 ;_-"US$"* "-"???????_ ;_-@_ ', key: '_-"US$"* #,##0.0000000_ ;_-"US$"* -#,##0.0000000 ;_-"US$"* "-"???????_ ;_-@_ ' },
        { showname: '_-"US$"* #,##0.00_ ;_-"US$"* -#,##0.00 ;_-"US$"* "-"??_ ;_-@_ ', key: '_-"US$"* #,##0.00_ ;_-"US$"* -#,##0.00 ;_-"US$"* "-"??_ ;_-@_ ' },
        { showname: '[$-409]mmmmm-yy;@', key: '[$-409]mmmmm-yy;@' },
        { showname: 'm/d/yy;@', key: 'm/d/yy;@' },
        { showname: getLabel('526874','yyyy"年"m"月";@'), key: getLabel('526874','yyyy"年"m"月";@') },
        { showname: getLabel('526872','yyyy"年"m"月"d"日";@'), key: getLabel('526872','yyyy"年"m"月"d"日";@') },
        { showname: '[$-804]aaa;@', key: '[$-804]aaa;@' },
        { showname: '[$-409]d-mmm-yy;@', key: '[$-409]d-mmm-yy;@' },
        { showname: 'h:mm:ss;@', key: 'h:mm:ss;@' },
        { showname: getLabel('526941','[$-409]h"时"mm"分" AM/PM;@') , key: getLabel('526941','[$-409]h"时"mm"分" AM/PM;@')  },
        { showname: '[$-409]h:mm:ss AM/PM;@', key: '[$-409]h:mm:ss AM/PM;@' },
        { showname: getLabel('526894','上午/下午h"时"mm"分";@'), key: getLabel('526894','上午/下午h"时"mm"分";@') },
        { showname: 'h:mm;@', key: 'h:mm;@' },
        { showname: '[$-409]h:mm AM/PM;@', key: '[$-409]h:mm AM/PM;@' },
        { showname: getLabel('526886','h"时"mm"分";@'), key: getLabel('526886','h"时"mm"分";@') },
        { showname: getLabel('526890','h"时"mm"分"ss"秒";@'), key: getLabel('526890','h"时"mm"分"ss"秒";@') },
        { showname: '# ?/2', key: '# ?/2' },
        { showname: getLabel('526942','[$-409]h"时"mm"分"ss"秒"_ AM/PM;@') , key: getLabel('526942','[$-409]h"时"mm"分"ss"秒"_ AM/PM;@') },
        { showname: '# ???/???', key: '# ???/???' },
        { showname: getLabel('526896','上午/下午h"时"mm"分"ss"秒";@'), key: getLabel('526896','上午/下午h"时"mm"分"ss"秒";@') },
        { showname: getLabel('526898','[DBNum1][$-804]h"时"mm"分";@'), key: getLabel('526898','[DBNum1][$-804]h"时"mm"分";@') },
        { showname: getLabel('526900','[DBNum1][$-804]上午/下午h"时"mm"分";@'), key: getLabel('526900','[DBNum1][$-804]上午/下午h"时"mm"分";@') },
        { showname: '0.000%', key: '0.000%' },
        { showname: '# ??/16', key: '# ??/16' },
        { showname: '# ?/10', key: '# ?/10' },
        { showname: '# ??/100', key: '# ??/100' },
    ]
    @observable selectFormatterType = "common";

    @observable formatter = "";

    @observable qfwCheck = false;
    @observable selectValueType;
    @observable selectDateType;
    @observable selectFenshuType;
    @observable selectTimeType;
    @observable xiaoshuvalue = 2;
    @observable huobiType;
    @observable formatterValue;
    @observable selectSpecialType;
    @observable selectDwwyType;
    @observable selectZfhType;
    @observable selectCustomType;

    huobiOptions = [{
        key: '1',
        showname: '无'
    }, {
        key: '￥',
        showname: '￥'
    }, {
        key: '€',
        showname: '€'
    }, {
        key: '$',
        showname: '$'
    }, {
        key: 'US$',
        showname: 'US$'
    }];

    countryType = [{
        key: 'china',
        showname: getLabel('526911','中文(中国)') 
    }]
    bottomShow = {
        common: "",
        value: getLabel('526912','数值格式用于一般数字的表示。货币和会计格式则提供货币值计算的专用格式。'),
        huobi: getLabel('526913','货币格式用于表示一般货币数值。会计格式可对一列数值进行小数点对齐'),
        kuaiji: getLabel('526914','会计格式可对一列数值进行货币符号和小数点对齐。'),
        date: getLabel('526915','日期格式把日期和时间系列数显示为日期值。'),
        time: getLabel('526916','时间格式把日期和时间序列数显示为时间值。'),
        percent:getLabel('526917','以百分数的形式显示单元格的值。'),
        fenshu: "",
        kexuejishu: "",
        text: "",
        special: getLabel('526918','特殊格式可用于跟踪数据列表及数据库的值。') ,
        custom: getLabel('526919','以现有格式为基础，生成自定义的数字格式。') ,
    };
    @observable bottomRemark = "";
    componentDidMount() {
        
    }
    
    @computed get getbottomRemark() {
        const FormatterTypeEnumLabel = new Map([
            
            ['数值格式用于一般数字的表示。货币和会计格式则提供货币值计算的专用格式。', getLabel('526912','数值格式用于一般数字的表示。货币和会计格式则提供货币值计算的专用格式。')],
            ['货币格式用于表示一般货币数值。会计格式可对一列数值进行小数点对齐。', getLabel('526913','货币格式用于表示一般货币数值。会计格式可对一列数值进行小数点对齐')],
            ['会计格式可对一列数值进行货币符号和小数点对齐。', getLabel('526914','会计格式可对一列数值进行货币符号和小数点对齐。')],
            ['日期格式把日期和时间系列数显示为日期值。', getLabel('526915','日期格式把日期和时间系列数显示为日期值。')],
            ['时间格式把日期和时间序列数显示为时间值。', getLabel('526916','时间格式把日期和时间序列数显示为时间值。')],
            ['以百分数的形式显示单元格的值。',  getLabel('526917','以百分数的形式显示单元格的值。') ],
            ['重复值', getLabel('527325','重复值')],
            ['特殊格式可用于跟踪数据列表及数据库的值。',getLabel('526918','特殊格式可用于跟踪数据列表及数据库的值。')],
            ['以现有格式为基础，生成自定义的数字格式。',getLabel('526919','以现有格式为基础，生成自定义的数字格式。') ],
            ['','']
        ]);
        
        this.bottomRemark = FormatterTypeEnum[this.selectFormatterType];
        const ReturnFormatterTypeEnumLabel = FormatterTypeEnumLabel.get(FormatterTypeEnum[this.selectFormatterType]);
        return ReturnFormatterTypeEnumLabel ;
    }
    getFieldOptions = (tables) => {
        return tables.map(table => ({
            key: '' + table.nameIndex,
            label: `${table.name}（${table.tableName}）`,
            options: table.fields.map(d => ({
                key: `${table.nameIndex}_${d.name}`,
                showname: d.text
            }))
        }))
    }
    
    @action getParentCellDataSetInfo = (dataSetId) => {
        return new Promise(r => {
            if (this.cache[dataSetId]) {
                r(this.cache[dataSetId]);
            } else {
                dataSetInfo(dataSetId).then(dataSetInfo => {
                    this.cache[dataSetId] = dataSetInfo;
                    r(dataSetInfo);
                })
            }
        })
    }
    
    @action getDefaultRange = (props) => {
        const sheet = props.getSheet();
        if (sheet) {

            //const activeCell = sheet.getActiveCell();
            const activeCell = sheet.getCell(sheet.getActiveRowIndex(),sheet.getActiveColumnIndex())
            
            // 数据格式
            const tag = activeCell.tag();
            if (tag && tag.formatterType && tag.formatterType.length > 0) {
                const formatterType = tag.formatterType;
                const selectType = formatterType[0];

                this.selectFormatterType = selectType;
                switch (selectType) {

                    case "value":
                        this.xiaoshuvalue = formatterType[1] === void 0 ? 2 : formatterType[1];
                        this.qfwCheck = formatterType[2] || false;
                        this.selectValueType = formatterType[3] || 1;
                        break;
                    case "huobi":
                        this.xiaoshuvalue = formatterType[1] === void 0 ? 2 : formatterType[1];
                        this.huobiType = formatterType[2] || '￥';
                        this.selectValueType = formatterType[3];
                        break;
                    case "kuaiji":
                        this.xiaoshuvalue = formatterType[1] === void 0 ? 2 : formatterType[1];
                        this.huobiType = formatterType[2] || '￥';
                        break

                    case "date":
                        this.selectDateType = formatterType[1];
                        break;
                    case "time":
                        this.selectTimeType = formatterType[1];
                        break;
                    case "percent":
                        this.xiaoshuvalue = formatterType[1] === void 0 ? 2 : formatterType[1];
                        break;
                    case "fenshu":
                        this.selectFenshuType = formatterType[1];
                        break;
                    case "special":
                        this.selectSpecialType = formatterType[1];
                        this.selectDwwyType = formatterType[2];
                        this.selectZfhType = formatterType[3];
                        break;
                    case "custom":
                        this.selectCustomType = formatterType[1];
                        break;
                    case "kexuejishu":
                        this.xiaoshuvalue = formatterType[1];
                        break;
                    case "shortdate":
                    this.selectFormatterType = 'date';
                    this.selectDateType = 'yyyy/m/d;@';
                    break;
                    case "longdate":
                    this.selectFormatterType = 'date';
                    this.selectDateType = getLabel('526920','yyyy"年"m"月"d"日";@');
                    break;

                }

            } else {
                this.selectFormatterType = 'common';
            }
        }

    }
    componentWillReceiveProps(nextProps) {
        if (this.props.visible !== nextProps.visible) {
            this.mainVisible = nextProps.visible;
            if (nextProps.visible) {
                this.getDefaultRange(nextProps);
            }
        }
    }



    onOk = () => {
        const { onOk, getSheet } = this.props;
        const sheet = getSheet();
        const selecttions = sheet.getSelections();
        const formatterType = [];
        formatterType.push(this.selectFormatterType);
        if (this.selectFormatterType == "value") {
            this.formatter = "";
            let qfw = "";
            let ws = "0";
            if (this.qfwCheck == true) {
                qfw = "#,##";
            }
            if ((this.xiaoshuvalue) > 0) {
                ws = ws + ".";
                for (let i = 0; i < this.xiaoshuvalue; i++) {
                    ws += "0";
                }
            }
            switch (this.selectValueType) {
                case "1":
                    this.formatter = qfw + ws + "_);[Red]\(" + qfw + ws + "\)";
                    break;
                case "2":
                    this.formatter = qfw + ws + "_);\(" + qfw + ws + "\)";
                    break;
                case "3":
                    this.formatter = qfw + ws + ";[Red]" + qfw + ws;
                    break;
                case "4":
                    this.formatter = qfw + ws + "_ ";
                    break;
                case "5":
                    this.formatter = qfw + ws + "_ ;[Red]\-" + qfw + ws + "\ ";
                    break;
                default:
                    this.formatter = qfw + ws + "_);[Red]\(" + qfw + ws + "\)";
            }

            formatterType.push(this.xiaoshuvalue);
            formatterType.push(this.qfwCheck);
            formatterType.push(this.selectValueType);
        } else if (this.selectFormatterType == "huobi") {
            let qfw = "#,##";
            const huobi = this.huobiType ? this.huobiType === '1' ? "" : '"' + this.huobiType + '"' : '"￥"';
            let ws = "0";
            if ((this.xiaoshuvalue) > 0) {
                ws = ws + ".";
                for (let i = 0; i < (this.xiaoshuvalue); i++) {
                    ws += "0";
                }
            }

            switch (this.selectValueType) {
                case "1":
                    this.formatter = huobi + qfw + ws + "_);[Red]\(" + huobi + qfw + ws + "\)";
                    break;
                case "2":
                    this.formatter = huobi + qfw + ws + "_);\(" + huobi + qfw + ws + "\)";
                    break;
                case "3":
                    this.formatter = huobi + qfw + ws + ";[Red]" + huobi + qfw + ws;
                    break;
                case "4":
                    this.formatter = huobi + qfw + ws + "_ ";
                    break;
                case "5":
                    this.formatter = huobi + qfw + ws + "_ ;[Red]\-" + huobi + qfw + ws + "\ ";
                    break;
                default:
                    this.formatter = huobi + qfw + ws + "_ ;[Red]\-" + huobi + qfw + ws + "\ ";
            }
            formatterType.push(this.xiaoshuvalue);
            formatterType.push(this.huobiType);
            formatterType.push(this.selectValueType);
        } else if (this.selectFormatterType == 'kuaiji') {
            let qfw = "#,##";
            const huobi = this.huobiType ? this.huobiType === '1' ? "" : '"' + this.huobiType + '"' : '"￥"';
            let ws = "0";
            let wenhao = "";
            if ((this.xiaoshuvalue) > 0) {
                ws = ws + ".";
                for (let i = 0; i < (this.xiaoshuvalue); i++) {
                    ws += "0";
                    wenhao += "?";
                }
            }
            this.formatter = "_ " + huobi + "* " + qfw + ws + "_ ;_ " + huobi + "* \-" + qfw + ws + "_ ;_ " + huobi + '* "-"' + wenhao + '_ ;_ @_ ';
            formatterType.push(this.xiaoshuvalue);
            formatterType.push(this.huobiType);
        } else if (this.selectFormatterType == 'date') {
            this.formatter = this.selectDateType ? this.selectDateType :getLabel('526920','yyyy"年"m"月"d"日";@');
            formatterType.push(this.selectDateType);
        } else if (this.selectFormatterType == 'time') {
            this.formatter = this.selectTimeType ? this.selectTimeType : 'h:mm:ss;@';
            formatterType.push(this.selectTimeType);
        } else if (this.selectFormatterType == 'percent') {
            let ws = "0";
            if ((this.xiaoshuvalue) > 0) {
                ws = ws + ".";
                for (let i = 0; i < (this.xiaoshuvalue); i++) {
                    ws += "0";
                }
            }
            this.formatter = ws + "%"
            formatterType.push(this.xiaoshuvalue);
        } else if (this.selectFormatterType == 'fenshu') {
            this.formatter = this.selectFenshuType ? this.selectFenshuType : '#\ ?/?';
            formatterType.push(this.formatter);
        } else if (this.selectFormatterType == 'special') {
            let f = this.selectSpecialType ? this.selectSpecialType : '000000';
            if (f === 'dwwy') {
                this.selectDwwyType = this.selectDwwyType ||  '0"."0,"'+getLabel('526864','万')+'"'
                f = this.selectDwwyType;
                this.selectZfhType = '';
            } else if (f === 'zfh') {
                this.selectZfhType = this.selectZfhType || '\+0;\-0;0;@';
                f = this.selectZfhType;
                this.selectDwwyType = '';
            } else {
                this.selectZfhType = '';
                this.selectDwwyType = '';
            }
            this.formatter = f;
            formatterType.push(this.selectSpecialType);
            formatterType.push(this.selectDwwyType);
            formatterType.push(this.selectZfhType);
        } else if (this.selectFormatterType == 'custom') {
            this.formatter = this.selectCustomType ? this.selectCustomType : 'General';
            if (this.formatter === getLabel('526910','G/通用格式')) {
                this.formatter = 'General';
            }
            formatterType.push(this.selectCustomType);
            // 此处可以在优化的更智能匹配选项
        } else if (this.selectFormatterType == 'kexuejishu') {
            let ws = "0";
            if ((this.xiaoshuvalue) > 0) {
                ws = ws + ".";
                for (let i = 0; i < (this.xiaoshuvalue); i++) {
                    ws += "0";
                }
            }
            this.formatter = ws + "E+00"
            formatterType.push(this.xiaoshuvalue);
        } else if (this.selectFormatterType == 'text') {
            this.formatter = "@";
        } else if (this.selectFormatterType == 'common') {
            this.formatter = "General";
        }

        onOk(this.formatter, formatterType);
        this.cancel();
    }


    cancel = () => {
        this.mainVisible = false;
        this.selectionVisible = false;
        this.props.toggleVisible(false);
    }


    /////////////////////数字格式////////////////////////

    @action onClickFormatterType = (value) => {
        const { key } = value;
        this.selectFormatterType = key;
        this.bottomRemark = FormatterTypeEnum[key];
    }

    @action changeQfwCheck = (value) => {
        this.qfwCheck = value;
    }

    @action onClickValueType = (value) => {
        const { key } = value;
        this.selectValueType = key;
    }

    @action onClickCustomType = (value) => {
        const { key } = value;
        this.selectCustomType = key;
    }

    @action onClickDateType = (value) => {
        const { key } = value;
        this.selectDateType = key;
    }

    @action onClickSpecialType = (value) => {
        const { key } = value;
        this.selectSpecialType = key;
    }
    // onClickDwwyType,selectDwwyType, onClickZfhType,selectZfhType
    @action onClickDwwyType = (value) => {
        const { key } = value;
        this.selectDwwyType = key;
    }

    @action onClickZfhType = (value) => {
        const { key } = value;
        this.selectZfhType = key;
    }
    @action onClickFenshuType = (value) => {
        const { key } = value;
        this.selectFenshuType = key;
    }

    @action onClickTimeType = (value) => {
        const { key } = value;
        this.selectTimeType = key;
    }

    @action onChangeXiaoshuwei = (value) => {
        this.xiaoshuvalue = value;
    }

    @action onChangeHuobiType = (value) => {
        this.huobiType = value;
    }

    @action changeCustomFormatter = (value) => {
        this.selectCustomType = value;
    }
    // changeCustomFormatter,formatterValue,
}